﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using Function;

namespace UI.Module.User
{
    public partial class UpdateTel : System.Web.UI.Page
    {
        MessageBox box = new MessageBox();
        protected string teltype = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            teltype = Request.QueryString["teltype"] ?? "";
            if (teltype=="1")
            {
                Label1.Text = "主要联系人";
                Label2.Text = "主要联系人";
            }else
            {
                Label1.Text = "紧急联系人";
                Label2.Text = "紧急联系人";
            }
        }

        protected void btnSet_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(username.Value) || username.Value == "请输入手机号")
            {
                tips.InnerHtml = "请输入手机号码";
                return;
            }
            if (string.IsNullOrEmpty(captcha.Value) || captcha.Value == "请输入验证码")
            {
                tips.InnerHtml = "请输入验证码";
                return;
            }
            if (Session["dtpwd"] != null && captcha.Value.Trim() != Session["dtpwd"].ToString().Trim())
            {
                tips.InnerHtml = "验证码错误!";
                return;
            }

            ST_InvestorBLL bll=new ST_InvestorBLL();
            ST_Investor model = bll.GetModel(Method.CurrentUserID);
            if (teltype == "1")
            {
                model.MainTel = this.username.Value;
            }
            else
            {
                model.UrgentTel = this.username.Value;
            }
            if (bll.Update(model))
            {
                box.SuccessBox(this, "联系人电话更改成功!", "UserMsge.aspx");
            }
            else
            {
                box.ErrorBox(this, "联系人电话更改失败!");
                return;
            }
        }
    }
}